<template>
  <div class="player-out">
    <div class="player-mask"></div>
    <el-image style="position:absolute;z-index: -1;width: 100%;height: 100%;border-radius: 20px;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="cover" />
    <div class="player-content">
      <div class="search">
        <el-input v-model="keyWords" placeholder="搜索歌曲" clearable>
          <template #prefix>
            <el-icon class="el-input__icon"><search /></el-icon>
          </template>
        </el-input>
      </div>
      <div class="list" :class="showList?'showList':''">
        <div class="list-item">
          <div class="song-message">
            <span class="collect"><span class="iconfont icon-xihuan"></span></span>
            <span class="song-title">{{curSong.song}} {{curSong.singer?'-':''}} {{curSong.singer}}</span>
          </div>
          <span class="del-item">×</span>
        </div>
      </div>
      <div class="song">
        <div class="collect">
          <span class="iconfont icon-xihuan"></span>
        </div>
        <div class="title">{{curSong.song}}{{curSong.singer?'-':''}}{{curSong.singer}}</div>
        <div class="icon-list" @click="showSongList">
          <span class="iconfont icon-yinpinliebiao"></span>
        </div>
      </div>
      <div class="player">
        <div class="prev iconfont icon-shangyishou"></div>
        <div class="controller" @click="pause">
          <div class="img-mask">
          </div>
          <el-image style="width: 60px; height: 60px;border-radius: 50%;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="cover" />
          <div class="play" :class="isPlay?'':'show'"><span class="iconfont icon-bofang"></span></div>
          <div class="pause" :class="isPlay?'show':''"><span class="iconfont icon-tingzhi"></span></div>
        </div>
        <div class="next iconfont icon-xiayishou"></div>
      </div>
      <div class="auido" :class="showAudio?'showAudio':''">
        <div class="progress"><el-slider v-model="value" vertical height="50px" input-size="small" /></div>
        <span class="iconfont icon-shengyin" @click="toggleShowAudio"></span>
      </div>
      <!-- <audio @timeupdate="handleTimeUpdate" @loadeddata="handleLoaded"
      :src="`https://dl.stream.qqmusic.qq.com/${playerData.url}`" ref="playerAudio" autoplay="autoplay"
      loop="loop"></audio> -->
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, reactive, watch, defineProps } from 'vue'
const props = defineProps(['songlist'])
const playerAudio = ref(null)
const showAudio = ref(false)
const value = ref(30)
const isPlay = ref(false)
const curSong = ref({
  song: '歌曲名',
  singer: '歌手名'
})
const keyWords = ref('')
const showList = ref(false)
const song = reactive({
  curSong: {
  },
  songlist: [],
  searchList: [],
  collectList: [],
  playerData: {
    url: ''
  }
})
console.log(props)
const toggleShowAudio = () => {
  showAudio.value = !showAudio.value
}
watch(props, newVal => {
  console.log(newVal);
});
const pause = () => {
  isPlay.value = !isPlay.value
  // if (isPlay.value) {
  //   playerAudio.value.play()
  // } else {
  //   playerAudio.value.pause()
  // }
}
// const handleTimeUpdate = (event) => {
//   if (event.target.currentTime + 1 >= this.$refs.player.duration) {
//     song.playerData = {}
//     nextSong()
//   }
// }
const showSongList = () => {
  showList.value = !showList.value
  console.log(showList.value)
}
</script>
<style scoped lang="scss">
@import url('https://at.alicdn.com/t/c/font_2035910_k5zilyg5s6a.css?spm=a313x.manage_type_myprojects.i1.9.34fa3a81rkrdgK&file=font_2035910_k5zilyg5s6a.css');
.player-out {
  position: fixed;
  width: 300px;
  right: 0;
  z-index: 999;
  border-radius: 20px;
  background: rgba(0,0,0,.5);
  border: 2px solid #fff;
  box-shadow: 0 0 10px 1px #000;
  user-select: none;
}
.auido {
  position: absolute;
  right: 35px;
  bottom: 10px;
  z-index: 2;
  .iconfont {
    font-size: 20px;
    color: #fff;
    cursor: pointer;
  }
  .progress {
    width: 20px;
    
  }
}
.search {
  padding: 10px;
  font-size: 12px;
  .el-input {
    .el-input__wrapper {
      background-color: transparent !important;
    }
  }
}
.iconfont {
  cursor: pointer;
}
.list {
  width: 100%;
  height: 0;
  padding: 10px 10px 0;
  overflow-y: scroll;
  transition: all .5s;
  scrollbar-width: none; /* 针对 Firefox */
  &::-webkit-scrollbar {
    display: none;
  }
  .list-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    height: 26px;
    line-height: 16px;
    padding: 5px;
    cursor: pointer;
    .del-item {
      font-size: 20px;
    }
    .song-message {
      flex: 1;
      display: flex;
      .song-title {
        width: 230px;
        height: 16px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
  .iconfont {
    font-size: 16px;
    vertical-align: middle;
  }
}
.list.showList {
  height: 200px;
}
.showList {
  scrollbar-width: none;
  
}
.song {
  display: flex;
  padding: 10px 10px 0;
  .title{
    flex: 1;
    text-align: center;
    color: #ffffff;
    font-size: 14px;
    line-height: 30px;
    height: 30px;
    text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .icon-list,.collect {
    width: 30px;
    height: 30px;
    line-height: 30px;
    .iconfont {
      font-size: 30px;
    }
  }
}
.player-content {
  position: relative;
  z-index: 1;
}
.player-mask {
  position: absolute;
  z-index: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  background-color: rgba(0, 0, 0, 0.5);
}
.player {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  font-size: 20px;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  .prev,.next {
    width: 40px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-radius: 50%;
    background-color: rgba(0,0,0,.5);
    margin: 0 10px;
  }
}
.controller {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  .img-mask {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0,0,0,.5);
    z-index: 1;
  }
  
  .play,.pause {
    position: absolute;
    width: 60px;
    height: 60px;
    text-align: center;
    border-radius: 50%;
    transform: rotate(360deg);
    z-index: 2;
    display: none;
    left: 0;
    top: 0;
  }
  .show {
    display: block !important;
    transform: all .5s;
    width: 60px;
    height: 60px;
  }
}
.iconfont {
  font-size: 40px;
}
</style>
<style lang="scss">
.search {
  padding: 10px;
  font-size: 12px;
  .el-input {
    height: 26px;
    line-height: 26px;
    font-size: 12px;
    border: rgba(255, 255, 255, .3);
    .el-input__inner {
      color: #fff !important;
      text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
    }
    .el-input__wrapper {
      background-color: transparent !important;
    }
  }
}
.progress {
  height: 0px;
  overflow: hidden;
  transition: all .5s;
  .el-slider {
    height: 0;
  }
  .el-slider.is-vertical .el-slider__runway {
    margin: 0 5px;
  }
  .el-slider__button {
    width: 10px;
    height: 10px;
  }
}
.auido.showAudio {
  .progress {
    width: 20px;
    height: 60px;
    padding-top: 30px;
  }
}
</style>